// nodeFirstEvent.js
// https://www.runoob.com/nodejs/nodejs-event-loop.html

var events = require("events");

var eventEmitter = new events.EventEmitter();

var connectHandler = function connected() {
    console.log("nodeFirstEvent connect Handler ");

    eventEmitter.emit("data_received");
}

eventEmitter.on("connection", connectHandler);

eventEmitter.on("data_received", function() {
    console.log("  data_received 数据接收成功");
});


eventEmitter.emit("connection");
eventEmitter.emit("connection");


console.log("nodeFirstEvent finish ");




